<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
      <el-form-item label="图纸名称" prop="lineName">
        <el-input
          v-model="queryParams.lineName"
          placeholder="请输入图纸名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="图号" prop="lineNumber">
        <el-input
          v-model="queryParams.lineNumber"
          placeholder="请输入图号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="图纸描述" prop="remark">
        <el-input
          v-model="queryParams.remark"
          placeholder="请输入图纸描述"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table
      v-loading="loading"
      :data="drawinglineList"
      border
    >
      <el-table-column label="图纸名称" align="center" prop="lineName" />
      <el-table-column label="图号" align="center" prop="lineNumber" />
      <el-table-column label="图纸描述" align="center" prop="remark" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleView(scope.row)"
            v-hasPermi="['md:drawingline:query']"
          >查看</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改图纸集Line对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1300px" append-to-body>
      <iframe
        :src="form.lineUrl"
        frameborder="0"
        scrolling="auto"
        style="width: 100%; height: 600px;"
      />
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listDrawingline,
  getDrawingline,
} from "@/api/mes/md/drawingline";

export default {
  name: "Drawingline",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 图纸集Line表格数据
      drawinglineList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        drawingId: null,
        lineName: null,
        lineNumber: null,
        lineUrl: null,
        remark: null,
        attr1: null,
        attr2: null,
        attr3: null,
        attr4: null
      },
      // 表单参数
      form: {},

    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询图纸集Line列表 */
    getList() {
      this.loading = true;
      listDrawingline(this.queryParams).then(response => {
        this.drawinglineList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        drawingId: null,
        lineName: null,
        lineNumber: null,
        lineUrl: null,
        remark: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        attr1: null,
        attr2: null,
        attr3: null,
        attr4: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 查看图纸
    handleView(row) {
      this.reset();
      this.open = true;
      getDrawingline(row.id).then(response => {
        this.form = response.data;
      })
    },

  }
};
</script>
